﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Gao.Poker.Domain;

namespace Gao.Poker.Services
{
    public class RechargeLogService : BaseService
    {
        private static RechargeLogService _instance;

        public static RechargeLogService Instance()
        {
            return _instance ?? (_instance = new RechargeLogService());
        }

        private RechargeLogService()
        {
            
        }

        public void Save(RechargeLog rechargeLog)
        {
            if (rechargeLog == null) return;

            if (rechargeLog.ID == 0)
            {
                DbContext.RechargeLogs.Add(rechargeLog);
            }
            else
            {
                var log = DbContext.RechargeLogs.Find(rechargeLog.ID);
                DbContext.Entry(log).CurrentValues.SetValues(rechargeLog);
            }
            DbContext.SaveChanges();
        }

        public List<RechargeLog> GetMemberRechargeLog(int memberId)
        {
            return DbContext.RechargeLogs.Where(a => a.MemberID == memberId).ToList();
        }
    }
}
